/*
 * Link.cpp
 *
 *  Created on: 17.04.2012
 *      Author: Eugene Kornykhin
 */

#include "Link.h"

#include <sstream>

Link::Link(string name, const Poliz &poliz)
: name(name), poliz(poliz) {

}

Link::~Link() {

}

string Link::getName() const {
	return name;
}

void Link::execute(Interpreter& interpreter) {
	interpreter.pushPolizElement(*this);
}

PolizPosition Link::next_position_after(PolizPosition p) const
{
	return p.next();
}

bool Link::isHalt() const {
	return false;
}

Link* Link::clone(const Poliz &p) const {
	return new Link(name, p);
}

string Link::toString() const {
	return "[LINK TO " + name + "]";
}

PolizPosition Link::getDestination() const
{
	return poliz.getDestination(name);
}

int Link::fresh_links = 0;

string Link::createFreshLinkName()
{
	std::stringstream s;
	s << "$" << fresh_links++;
	return s.str();
}
